<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'site-administrator-form',
    'enableAjaxValidation' => false,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<div class="block">
    <div class="alert alert_grey">
        <img height="24" width="24" src="<?php echo Yii::app()->params['backendUrl']; ?>/images/icons/small/grey/alert_2.png">
        Fields with <span class="required"><strong>*</strong></span> are required.
    </div>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

    <div class="input_group">
        <?php echo $form->labelEx($model, 'administrator_administrator_group_id'); ?>
        <?php
        if (Yii::app()->user->administrator_group_type == 'superuser') {
            echo $form->dropDownList($model, 'administrator_administrator_group_id', CHtml::listData(site_administrator_group::model()->findAll(), 'administrator_group_id', 'administrator_group_title'), array('prompt' => 'Select Administrator Group'));
        }
        else {
            echo $form->dropDownList($model, 'administrator_administrator_group_id', CHtml::listData(site_administrator_group::model()->findAllByAttributes(array('administrator_group_type' => 'administrator')), 'administrator_group_id', 'administrator_group_title'), array('prompt' => 'Select Administrator Group'));
        }
        ?>
        <?php //echo $form->error($model, 'administrator_administrator_group_id'); ?>
    </div>

    <?php echo $form->labelEx($model, 'administrator_username'); ?>
    <?php echo $form->textField($model, 'administrator_username', array('size' => 30, 'maxlength' => 50)); ?>
    <?php //echo $form->error($model, 'administrator_username'); ?>

    <?php if($model->isNewRecord) : ?>
    <?php echo $form->labelEx($model, 'administrator_new_password'); ?>
    <?php echo $form->passwordField($model, 'administrator_new_password', array('size' => 30, 'maxlength' => 255)); ?>
    <?php //echo $form->error($model, 'administrator_new_password'); ?>

    <?php echo $form->labelEx($model, 'administrator_confirm_password'); ?>
    <?php echo $form->passwordField($model, 'administrator_confirm_password', array('size' => 30, 'maxlength' => 255)); ?>
    <?php //echo $form->error($model, 'administrator_confirm_password'); ?>
    <?php endif; ?>

    <?php echo $form->labelEx($model, 'administrator_name'); ?>
    <?php echo $form->textField($model, 'administrator_name', array('size' => 60, 'maxlength' => 255)); ?>
    <?php //echo $form->error($model, 'administrator_name'); ?>

    <?php echo $form->labelEx($model, 'administrator_phone'); ?>
    <?php echo $form->textField($model, 'administrator_phone', array('size' => 30, 'maxlength' => 255)); ?>
    <?php //echo $form->error($model, 'administrator_phone'); ?>
    
    <div class="input_group">
        <?php echo $form->labelEx($model, 'administrator_image'); ?>
        <?php
        if(!$model->isNewRecord && $model->administrator_image != null) {
            echo '<div>'.CHtml::image(Yii::app()->params['config']['dir']['admin'].$model->administrator_image, (($model->administrator_image != null) ? $model->administrator_name : ''), array('width' => 55)).'</div>';
        }
        ?>
        <?php echo CHtml::activeFileField($model, 'administrator_image'); ?>
        <?php //echo $form->error($model, 'administrator_image'); ?>
    </div>

    <button class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="<?php echo Yii::app()->params['backendUrl']; ?>/images/icons/small/white/bended_arrow_right.png"><span><?php echo ($model->isNewRecord) ? 'Create' : 'Save'; ?></span></button>

</div>

<?php $this->endWidget(); ?>

<!-- form -->